using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Decisions.HL7.Message;
using DecisionsFramework;

namespace Decisions.HL7.Message
{
    public class BodySiteAttribute:RuleAttribute
    {
        private Dictionary<HL7Version, string[]> validVersionCodes = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, string[]> validVersionDescriptions = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, HL7TableType> tableVersionTypes = new Dictionary<HL7Version, HL7TableType>();

        public BodySiteAttribute()
        {
            // init the values for table version types
						tableVersionTypes[HL7Version.v23] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v231] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v24] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v25] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v251] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v26] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v27] = HL7TableType.HL7;
			
            
			// init the values for version codes
						validVersionCodes[HL7Version.v23] = new string[]{"BE","BN","BU","CT","LA","LAC","LACF","LD","LE","LEJ","LF","LG","LH","LIJ","LLAQ","LLFA","LMFA","LN","LNB","LPC","LSC","LT","LUA","LUAQ","LUFA","LV","LVG","OD","OS","OU","PA","PERIN","RA","RAC","RACF","RD","RE","REJ","RF","RG","RH","RIJ","RLAQ","RLFA","RMFA","RN","RPC","RSC","RT","RUA","RUAQ","RUFA","RVG","RVL","LVL","NB"};
						validVersionCodes[HL7Version.v231] = new string[]{"BE","OU","BN","BU","CT","LA","LAC","LACF","LD","LE","LEJ","OS","LF","LG","LH","LIJ","LLAQ","LLFA","LMFA","LN","LPC","LSC","LT","LUA","LUAQ","LUFA","LVG","LVL","NB","PA","PERIN","RA","RAC","RACF","RD","RE","REJ","OD","RF","RG","RH","RIJ","RLAQ","RLFA","RMFA","RN","RPC","RSC","RT","RUA","RUAQ","RUFA","RVL","RVG"};
						validVersionCodes[HL7Version.v24] = new string[]{"BE","OU","BN","BU","CT","LA","LAC","LACF","LD","LE","LEJ","OS","LF","LG","LH","LIJ","LLAQ","LLFA","LMFA","LN","LPC","LSC","LT","LUA","LUAQ","LUFA","LVG","LVL","NB","PA","PERIN","RA","RAC","RACF","RD","RE","REJ","OD","RF","RG","RH","RIJ","RLAQ","RLFA","RMFA","RN","RPC","RSC","RT","RUA","RUAQ","RUFA","RVL","RVG"};
						validVersionCodes[HL7Version.v25] = new string[]{"BE","OU","BN","BU","CT","LA","LAC","LACF","LD","LE","LEJ","OS","LF","LG","LH","LIJ","LLAQ","LLFA","LMFA","LN","LPC","LSC","LT","LUA","LUAQ","LUFA","LVG","LVL","NB","PA","PERIN","RA","RAC","RACF","RD","RE","REJ","OD","RF","RG","RH","RIJ","RLAQ","RLFA","RMFA","RN","RPC","RSC","RT","RUA","RUAQ","RUFA","RVL","RVG"};
						validVersionCodes[HL7Version.v251] = new string[]{"BE","OU","BN","BU","CT","LA","LAC","LACF","LD","LE","LEJ","OS","LF","LG","LH","LIJ","LLAQ","LLFA","LMFA","LN","LPC","LSC","LT","LUA","LUAQ","LUFA","LVG","LVL","NB","PA","PERIN","RA","RAC","RACF","RD","RE","REJ","OD","RF","RG","RH","RIJ","RLAQ","RLFA","RMFA","RN","RPC","RSC","RT","RUA","RUAQ","RUFA","RVL","RVG"};
						validVersionCodes[HL7Version.v26] = new string[]{"BE","OU","BN","BU","CT","LA","LAC","LACF","LD","LE","LEJ","OS","LF","LG","LH","LIJ","LLAQ","LLFA","LMFA","LN","LPC","LSC","LT","LUA","LUAQ","LUFA","LVG","LVL","NB","PA","PERIN","RA","RAC","RACF","RD","RE","REJ","OD","RF","RG","RH","RIJ","RLAQ","RLFA","RMFA","RN","RPC","RSC","RT","RUA","RUAQ","RUFA","RVL","RVG"};
						validVersionCodes[HL7Version.v27] = new string[]{"BE","OU","BN","BU","CT","LA","LAC","LACF","LD","LE","LEJ","OS","LF","LG","LH","LIJ","LLAQ","LLFA","LMFA","LN","LPC","LSC","LT","LUA","LUAQ","LUFA","LVG","LVL","NB","PA","PERIN","RA","RAC","RACF","RD","RE","REJ","OD","RF","RG","RH","RIJ","RLAQ","RLFA","RMFA","RN","RPC","RSC","RT","RUA","RUAQ","RUFA","RVL","RVG"};
			
			// init the values for version descriptions
						validVersionDescriptions[HL7Version.v23] = new string[]{"Bilateral Ears","Bilateral Nares","Buttock","Chest Tube","Left Arm","Left Anterior Chest","Left Antecubital Fossa","Left Deltoid","Left Ear","Left External Jugular","Left Foot","Left Gluteus Medius","Left Hand","Left Internal Jugular","Left Lower Abd Quadrant","Left Lower Forearm","Left Mid Forearm","Left Naris","Nebulized","Left Posterior Chest","Left Subclavian","Left Thigh","Left Upper Arm","Left Upper Abd Quadrant","Left Upper Forearm","Left Vastus Lateralis","Left Ventragluteal","Right Eye","Left Eye","Bilateral Eyes","Perianal","Perineal","Right Arm","Right Anterior Chest","Right Antecubital Fossa","Right Deltoid","Right Ear","Right External Jugular","Right Foot","Right Gluteus Medius","Right Hand","Right Internal Jugular","Rt Lower Abd Quadrant","Right Lower Forearm","Right Mid Forearm","Right Naris","Right Posterior Chest","Right Subclavian","Right Thigh","Right Upper Arm","Right Upper Abd Quadrant","Right Upper Forearm","Right Ventragluteal","Right Vastus Lateralis","Left Vastus Lateralis","Nebulized"};
						validVersionDescriptions[HL7Version.v231] = new string[]{"Bilateral Ears","Bilateral Eyes","Bilateral Nares","Buttock","Chest Tube","Left Arm","Left Anterior Chest","Left Antecubital Fossa","Left Deltoid","Left Ear","Left External Jugular","Left Eye","Left Foot","Left Gluteus Medius","Left Hand","Left Internal Jugular","Left Lower Abd Quadrant","Left Lower Forearm","Left Mid Forearm","Left Naris","Left Posterior Chest","Left Subclavian","Left Thigh","Left Upper Arm","Left Upper Abd Quadrant","Left Upper Forearm","Left Ventragluteal","Left Vastus Lateralis","Nebulized","Perianal","Perineal","Right Arm","Right Anterior Chest","Right Antecubital Fossa","Right Deltoid","Right Ear","Right External Jugular","Right Eye","Right Foot","Right Gluteus Medius","Right Hand","Right Internal Jugular","Rt Lower Abd Quadrant","Right Lower Forearm","Right Mid Forearm","Right Naris","Right Posterior Chest","Right Subclavian","Right Thigh","Right Upper Arm","Right Upper Abd Quadrant","Right Upper Forearm","Right Vastus Lateralis","Right Ventragluteal"};
						validVersionDescriptions[HL7Version.v24] = new string[]{"Bilateral Ears","Bilateral Eyes","Bilateral Nares","Buttock","Chest Tube","Left Arm","Left Anterior Chest","Left Antecubital Fossa","Left Deltoid","Left Ear","Left External Jugular","Left Eye","Left Foot","Left Gluteus Medius","Left Hand","Left Internal Jugular","Left Lower Abd Quadrant","Left Lower Forearm","Left Mid Forearm","Left Naris","Left Posterior Chest","Left Subclavian","Left Thigh","Left Upper Arm","Left Upper Abd Quadrant","Left Upper Forearm","Left Ventragluteal","Left Vastus Lateralis","Nebulized","Perianal","Perineal","Right Arm","Right Anterior Chest","Right Antecubital Fossa","Right Deltoid","Right Ear","Right External Jugular","Right Eye","Right Foot","Right Gluteus Medius","Right Hand","Right Internal Jugular","Rt Lower Abd Quadrant","Right Lower Forearm","Right Mid Forearm","Right Naris","Right Posterior Chest","Right Subclavian","Right Thigh","Right Upper Arm","Right Upper Abd Quadrant","Right Upper Forearm","Right Vastus Lateralis","Right Ventragluteal"};
						validVersionDescriptions[HL7Version.v25] = new string[]{"Bilateral Ears","Bilateral Eyes","Bilateral Nares","Buttock","Chest Tube","Left Arm","Left Anterior Chest","Left Antecubital Fossa","Left Deltoid","Left Ear","Left External Jugular","Left Eye","Left Foot","Left Gluteus Medius","Left Hand","Left Internal Jugular","Left Lower Abd Quadrant","Left Lower Forearm","Left Mid Forearm","Left Naris","Left Posterior Chest","Left Subclavian","Left Thigh","Left Upper Arm","Left Upper Abd Quadrant","Left Upper Forearm","Left Ventragluteal","Left Vastus Lateralis","Nebulized","Perianal","Perineal","Right Arm","Right Anterior Chest","Right Antecubital Fossa","Right Deltoid","Right Ear","Right External Jugular","Right Eye","Right Foot","Right Gluteus Medius","Right Hand","Right Internal Jugular","Rt Lower Abd Quadrant","Right Lower Forearm","Right Mid Forearm","Right Naris","Right Posterior Chest","Right Subclavian","Right Thigh","Right Upper Arm","Right Upper Abd Quadrant","Right Upper Forearm","Right Vastus Lateralis","Right Ventragluteal"};
						validVersionDescriptions[HL7Version.v251] = new string[]{"Bilateral Ears","Bilateral Eyes","Bilateral Nares","Buttock","Chest Tube","Left Arm","Left Anterior Chest","Left Antecubital Fossa","Left Deltoid","Left Ear","Left External Jugular","Left Eye","Left Foot","Left Gluteus Medius","Left Hand","Left Internal Jugular","Left Lower Abd Quadrant","Left Lower Forearm","Left Mid Forearm","Left Naris","Left Posterior Chest","Left Subclavian","Left Thigh","Left Upper Arm","Left Upper Abd Quadrant","Left Upper Forearm","Left Ventragluteal","Left Vastus Lateralis","Nebulized","Perianal","Perineal","Right Arm","Right Anterior Chest","Right Antecubital Fossa","Right Deltoid","Right Ear","Right External Jugular","Right Eye","Right Foot","Right Gluteus Medius","Right Hand","Right Internal Jugular","Rt Lower Abd Quadrant","Right Lower Forearm","Right Mid Forearm","Right Naris","Right Posterior Chest","Right Subclavian","Right Thigh","Right Upper Arm","Right Upper Abd Quadrant","Right Upper Forearm","Right Vastus Lateralis","Right Ventragluteal"};
						validVersionDescriptions[HL7Version.v26] = new string[]{"Bilateral Ears","Bilateral Eyes","Bilateral Nares","Buttock","Chest Tube","Left Arm","Left Anterior Chest","Left Antecubital Fossa","Left Deltoid","Left Ear","Left External Jugular","Left Eye","Left Foot","Left Gluteus Medius","Left Hand","Left Internal Jugular","Left Lower Abd Quadrant","Left Lower Forearm","Left Mid Forearm","Left Naris","Left Posterior Chest","Left Subclavian","Left Thigh","Left Upper Arm","Left Upper Abd Quadrant","Left Upper Forearm","Left Ventragluteal","Left Vastus Lateralis","Nebulized","Perianal","Perineal","Right Arm","Right Anterior Chest","Right Antecubital Fossa","Right Deltoid","Right Ear","Right External Jugular","Right Eye","Right Foot","Right Gluteus Medius","Right Hand","Right Internal Jugular","Rt Lower Abd Quadrant","Right Lower Forearm","Right Mid Forearm","Right Naris","Right Posterior Chest","Right Subclavian","Right Thigh","Right Upper Arm","Right Upper Abd Quadrant","Right Upper Forearm","Right Vastus Lateralis","Right Ventragluteal"};
						validVersionDescriptions[HL7Version.v27] = new string[]{"Bilateral Ears","Bilateral Eyes","Bilateral Nares","Buttock","Chest Tube","Left Arm","Left Anterior Chest","Left Antecubital Fossa","Left Deltoid","Left Ear","Left External Jugular","Left Eye","Left Foot","Left Gluteus Medius","Left Hand","Left Internal Jugular","Left Lower Abd Quadrant","Left Lower Forearm","Left Mid Forearm","Left Naris","Left Posterior Chest","Left Subclavian","Left Thigh","Left Upper Arm","Left Upper Abd Quadrant","Left Upper Forearm","Left Ventragluteal","Left Vastus Lateralis","Nebulized","Perianal","Perineal","Right Arm","Right Anterior Chest","Right Antecubital Fossa","Right Deltoid","Right Ear","Right External Jugular","Right Eye","Right Foot","Right Gluteus Medius","Right Hand","Right Internal Jugular","Rt Lower Abd Quadrant","Right Lower Forearm","Right Mid Forearm","Right Naris","Right Posterior Chest","Right Subclavian","Right Thigh","Right Upper Arm","Right Upper Abd Quadrant","Right Upper Forearm","Right Vastus Lateralis","Right Ventragluteal"};
			            

        }

        
        public override ValidationIssue[] RunRule(string name, object owningObject, object value)
        {
            //todo: check if the value is valid in the current version
            //if the value is not valid in the current version, add it as a validation issue


            return new ValidationIssue[0];
        }
    }
}
